{include file="user:header" /}
<link href="/static/user/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
<script src="/static/user/js/plugins/sweetalert/sweetalert.min.js"></script>
<style>
.biaoge .goods_spec a {
    display: inline-block;
    margin-right: 8px;
    margin-bottom:8px;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    -o-transition: all 0.3s;
    transition: all 0.3s;
    padding: 4px 14px;
    background: #efefef;
    color: #000;
    background-color: #fff;
    border: 1px solid #ddd;
}
.biaoge .goods_spec a.hover {
    color: #e4393c;
    background-color: #fff;
    border: 2px solid #e4393c;
}
.biaoge .price{color: #ff0000;margin-left: 5px;}
</style>
</head>

<body class="gray-bg">
	
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row"> 
  <!--头部面包屑-->
  <div class="col-lg-12">
  
    <div class="ibox">
      <div class="ibox-content-p5 text-center">
        <div class="breadcrumb"> <i class="fa fa-home m-r5" style=" font-size: 16px;"></i>
          <li><a href="/user/index">首页</a></li>
            <li><a href="/user/market">应用市场</a></li>
          <li class="active">{$info['name']}</li>
        </div>
      </div>
    </div>

    <!--表格-->
    <div class="ibox float-e-margins">
		<div class="ibox-title"><h3>应用详情</h3></div>
<div class="ibox-content">
	<form method="post" class="form-horizontal" action="{:url('order')}" id="myform">
        <input type="hidden" name="attr_id" id="attr_id" value="">
        <input type="hidden" name="gid" value="{$info['id']}">
		<div class="biaoge">
                <label class="col-sm-1 control-label">应用名称</label>
                <div class="col-sm-2">
                    <p class="form-control-static">{$info['name']}</p>
                </div>
        </div>


                    <?php
  if($info['attr_groups']){
     $option_ary=json_decode($info['attr_groups'],true);
     if($option_ary&&count($option_ary)>0){
                    foreach($option_ary as $val){
                    ?>
                     <div class="hr-line-dashed"></div>

                          <div class="biaoge" data="{$val['skuTypeKey']}">
                          <label class="col-sm-1 control-label">{$val['skuTypeTitle']}</label>
                          <div class="col-sm-3 goods_spec goods_attr" data="{$val['skuTypeKey']}">
                                <?php foreach($val['skuValues'] as $key=>$vo){ ?>
                                <a data="{$vo['skuValueId']}" href="javascript:;">{$vo['skuValueTitle']}</a>
                                <?php } ?>
                          </div>
                      </div>

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     <script type="text/javascript">
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   var attr_gid={$info['id']};
$(function(){
   $(".goods_attr a").click(function() {
      $(this).siblings().removeClass('hover');
      $(this).addClass('hover');
      getGoods();
   })
})

function getGoods(){
    var gids=[];
    var is_all=true; //全部选中
    $(".goods_attr").each(function(){
    var i=$(this).find(".hover").attr('data');
         if(!i)is_all=false;
         gids.push(i);
    })
   var code=gids.join(";");
if(is_all) {
$.getJSON('/user/sku',{gid:attr_gid,code:code}, function(res) {
    $(".price").html(res.price);
    $(".stock").html(res.stock);
    attr_id=res.id;
    $("#attr_id").val(res.id);
    $(".submit_btn").removeClass("btn-disabled").addClass("btn-success");
});
}
}
</script>

                    <?php
      }}
	 }
?>



        <div class="hr-line-dashed"></div>
        <div class="biaoge">
            <label class="col-sm-1 control-label">售价</label>
            <div class="col-sm-3">
                <p class="form-control-static">￥<span class="price">--</span></p>
            </div>
        </div>

        <!--
        <div class="hr-line-dashed"></div>
        <div class="biaoge">
            <label class="col-sm-1 control-label">库存</label>
            <div class="col-sm-10">
                  <p class="form-control-static"><span class="stock">--</span></p>
            </div>
        </div>
        </div>
        -->

    	<div class="hr-line-dashed"></div>
		<div class="biaoge">
            <label class="col-sm-1 control-label"></label>
                <div class="col-sm-10">
                   <button type="button" onclick="sumitPost();" class="btn btn-w-m btn-disabled submit_btn">提交订单</button>
                </div>
        </div>
	
	
	</form>
		</div>
  </div>
</div>
<script>
function sumitPost(){
if($(".submit_btn").hasClass("btn-disabled"))return false;

        swal({
            title: "确认下单",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确认",
            cancelButtonText:"取消",
            closeOnConfirm: true
        }, function () {
            ajaxpost('myform');
            return;
        });


}
</script>

{include file="user:footer" /}